﻿using System.Collections.Generic;
using Uber.Core;
using Uber.Core.Model;
using Uber.Core.Repository;
using Uber.Core.Service;

namespace Uber.Service
{
    public class OPros : IOPros
    {
        private readonly IOProRepo repo;

        public OPros(IOProRepo repo)
        {
            this.repo = repo;
        }

        public OPro Get(string name)
        {
            return repo.Get(name);
        }

        public IPageable<OPro> GetPage(int page, int pageSize)
        {
            return new Pageable<OPro>
                        {
                            PageIndex = page,
                            Page = repo.GetPage(page, pageSize),
                            PageCount = ServiceUtils.GetPageCount(pageSize, repo.Count())
                        };
        }
    }
}